package com.example.lenovo.helloworld;

import android.app.ActionBar;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageButton;




public class MainActivity extends Activity implements View.OnClickListener {

    private ImageButton image_chat;
    private ImageButton image_list;
    private ImageButton image_find;
    private ImageButton image_me;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        //顶部菜单栏屏蔽
        ActionBar actionBar = getActionBar();
        if (actionBar != null) {
            actionBar.hide();
        }
        //注册底部4个按钮
        image_chat = (ImageButton) findViewById(R.id.img_chat);
        image_list = (ImageButton) findViewById(R.id.img_list);
        image_find = (ImageButton) findViewById(R.id.img_find);
        image_me = (ImageButton) findViewById(R.id.img_me);

        image_chat.setOnClickListener(this);
        image_list.setOnClickListener(this);
        image_find.setOnClickListener(this);
        image_me.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        setTabDefaultColor();
        switch (v.getId()) {
            case R.id.img_chat:
                image_chat.setImageResource(R.drawable.weixin_pressed);
                break;
            case R.id.img_list:
                image_list.setImageResource(R.drawable.contact_list_pressed);
                break;
            case R.id.img_find:
                image_find.setImageResource(R.drawable.find_pressed);
                break;
            case R.id.img_me:
                image_me.setImageResource(R.drawable.contact_list_pressed);
                break;
        }
    }

    private void setTabDefaultColor() {
        image_chat.setImageResource(R.drawable.weixin_normal);
        image_list.setImageResource(R.drawable.contact_list_normal);
        image_find.setImageResource(R.drawable.find_normal);
        image_me.setImageResource(R.drawable.contact_list_normal);
    }

}
